﻿using Sdk;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace DiverseStudents.UI
{
    internal partial class UICreate
    {
        public static UISprite ItemBgSprite(bool _show = true)
        {

            try
            {
                if (detailIntentView != null)
                {
                    // string path = ispress ? "Cell_AchievementItem/icon_progress" : "Cell_AchievementItem/icon_bg";
                    var bg = detailIntentView.transform.Find("group_data/Scroll View/Viewport/itemgroup_list/Cell_DetailIntentItem/icon_bg");
                    if (bg != null && bg != default)
                    {
                        DLog.Warring("Find");
                        return new UISprite(GameObject.Instantiate(bg.gameObject));
                    }
                }
            }
            catch (Exception ex)
            {
                DLog.Error(ex);
            }
            DLog.Warring("Not find iocn");
            return CreateErrorT<UISprite>();
        }

        public static Sprite BeseRectBackImage( bool _show = true)
        {
            if (detailIntentView != null)
            {
                var gi = detailIntentView.FindComponent<RectTransform>("group_data/group_intent");
                if (gi != null && gi != default)
                {
                    var giImg =  gi.GetComponent<Image>();
                    if(giImg != null)
                    {
                    
                      return GameObject.Instantiate(giImg.sprite);
                    }
                }
                else
                {
                    DLog.Warring("Not find BeseRectStyle1");
                }
            }
            var rect = CreateErrorT<Sprite>();
            return rect;
        }

    }
}
